<?php
	require '../../include/library.inc.php';
	require '../../include/admin_login.inc.php';
	
	    $sql = "SELECT
						*
					FROM
						album_images_description
					WHERE
						album_id = '".intval($_POST['album'])."'
						AND
						image = '".$_POST['file']."'
						AND
						lang_id = '".$_POST['lang']."'
					  ";
		$res = query($sql);
		if ($row_check = mysql_fetch_object($res)) {
			
			$sql1 = "UPDATE album_images_description SET
				       description = '".escape($_POST['description'])."'
				    WHERE
						album_id = '".intval($_POST['album'])."'
						AND
						image = '".$_POST['file']."'
						AND
						lang_id = '".$_POST['lang']."'
				";
			query($sql1);
			echo "Описанието е запазено";
		}else{
			
			$sql2 = "INSERT INTO album_images_description
					(album_id,lang_id,image,description)
					VALUES
					('".intval($_POST['album'])."','".intval($_POST['lang'])."','".$_POST['file']."','".escape($_POST['description'])."')";
					query($sql2);
					echo "Описанието е запазено";
		}
?>